<?php 
include_once('connection/connection.php');
//session_start();
//ob_start();
include('header.php');
include('menu.php');
$check=$_SESSION['check'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<script language="Javascript" type="text/javascript" src="js/ajaxFunction1.js"></script>
<script language=javascript>
function show_button()
{
	document.getElementById('submit').disabled=false;
}
</script>
<title>Questionnaire No.3</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
		$fclick = true;
		$loc_id = $_SESSION['loc_id'];
		$num_glrs=$_POST['num_glrs'];
		$num_glsr=$_POST['num_glsr'];
		$sc_st_glr=$_POST['sc_st_glr'];
		$sc_st_glsr=$_POST['sc_st_glsr'];
		$check=$_POST['check_value'];
		if($_POST['num_glrs']!=0 || $_POST['num_glrs']!='' || $_POST['num_glsr']!=0 || $_POST['num_glsr']!='')
		{
			$qr1="UPDATE tbl_dtls_q3_loc SET num_glrs = '$num_glrs', num_glsr = '$num_glsr', sc_st_glr = '$sc_st_glr', sc_st_glsr = '$sc_st_glsr' WHERE id='$loc_id'";	
			$result1=mysql_query($qr1);
			if($result1)
			{
				//echo "Success";
				header('Location: questionnaire3_6.php');	
			}
			if($num_glrs >0) {
			for($i=1; $i<=$num_glrs; $i++)
			{	
				$glrs_id='glrs_id'.$i;
				$glrs_location='glrs_location'.$i;
				$glrs_longitude='glrs_longitude'.$i;
				$glrs_latitude='glrs_latitude'.$i;
				$glrs_supply='glrs_supply'.$i;
				$glrs_capacity='glrs_capacity'.$i;
				$glrs_status='glrs_status'.$i;
				$glrs_condition='glrs_condition'.$i;
				$glrs_connect='glrs_connect'.$i;
				
				$glrs_id=$_POST[$glrs_id];
				$glrs_location=$_POST[$glrs_location];
				$glrs_longitude=$_POST[$glrs_longitude];
				$glrs_latitude=$_POST[$glrs_latitude];
				$glrs_supply=$_POST[$glrs_supply];
				$glrs_capacity=$_POST[$glrs_capacity];
				$glrs_status=$_POST[$glrs_status];
				$glrs_condition=$_POST[$glrs_condition];
				$glrs_connect=$_POST[$glrs_connect];
				
				$qr2="INSERT INTO tbl_dtls_q3_reservoirs(loc_id, reserv_id, reserv_location, reserv_longitude, reserv_latitude, reserv_supply, reserv_capacity, reserv_status, reserv_condition, reserv_connect) VALUES ('$loc_id', '$glrs_id', '$glrs_location', '$glrs_longitude', '$glrs_latitude', '$glrs_supply', '$glrs_capacity', '$glrs_status', '$glrs_condition', '$glrs_connect')";
				//echo $qr2;
				$result2=mysql_query($qr2);
			}
			}
				if($result2)
				{
					//echo "Success";
					header('Location: questionnaire3_6.php');	
				}	
			if($num_glsr >0) {	
			for($i=1; $i<=$num_glsr; $i++)
			{
				$glsr_id='glsr_id'.$i;
				$glsr_location='glsr_location'.$i;
				$glsr_longitude='glsr_longitude'.$i;
				$glsr_latitude='glsr_latitude'.$i;
				$glsr_supply='glsr_supply'.$i;
				$glsr_capacity='glsr_capacity'.$i;
				$glsr_status='glsr_status'.$i;
				$glsr_condition='glsr_condition'.$i;
				$glsr_connect='glsr_connect'.$i;
				
				$glsr_id=$_POST[$glsr_id];
				$glsr_location=$_POST[$glsr_location];
				$glsr_longitude=$_POST[$glsr_longitude];
				$glsr_latitude=$_POST[$glsr_latitude];
				$glsr_supply=$_POST[$glsr_supply];
				$glsr_capacity=$_POST[$glsr_capacity];
				$glsr_status=$_POST[$glsr_status];
				$glsr_condition=$_POST[$glsr_condition];
				$glsr_connect=$_POST[$glsr_connect];
				
				$qr3="INSERT INTO tbl_dtls_q3_reservoirs(loc_id, reserv_id, reserv_location, reserv_longitude, reserv_latitude, reserv_supply, reserv_capacity, reserv_status, reserv_condition, reserv_connect) VALUES ('$loc_id', '$glsr_id', '$glsr_location', '$glsr_longitude', '$glsr_latitude', '$glsr_supply', '$glsr_capacity', '$glsr_status', '$glsr_condition', '$glsr_connect')";
				//echo $qr3;
				$result3=mysql_query($qr3);
			}
			}
				if($result3)
				{
					//echo "Success";
					header('Location: questionnaire3_6.php');	
				}
		}	
		else if($_POST['num_glsr']=='0' || $_POST['num_glrs']=='0')
		{
			$qr1="UPDATE tbl_dtls_q3_loc SET num_glrs = '$num_glrs', num_glsr = '$num_glsr', sc_st_glr = '$sc_st_glr', sc_st_glsr = '$sc_st_glsr' WHERE id='$loc_id'";	
			$result1=mysql_query($qr1);
			if($result1)
			{
				//echo "Success";
				header('Location: questionnaire3_6.php');	
			}
		}					
}				
else
{
	$fclick = false;
	$flag=0;
}
?>		
<div align="center">
<form action="" method="post" enctype="multipart/form-data" name="questionnaire3_5" id="questionnaire3_5" onSubmit="return validate5()">
<input type="hidden" name="check_value" id="check_value" value="<?php echo $check;?>" class="txt5">
	<table border="0" width="800" id="table1" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30" colspan="2">
			<p align="center">
			<font face="Verdana" style="font-size: 10pt; font-weight: 700" color="#000000">
			Questionnaire No. 3</font></td>
		</tr>
		<tr>
			<td height="19" colspan="2">
			<p align="center">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">For 
			Field Survey (Village Level questionnaire) </font></td>
		</tr>
		<tr>
			<td height="18" colspan="2">
			<p align="center">
			<font style="font-size: 8.5pt" face="Arial" color="#000000">Page 5</font></td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
		<tr>
			<td height="20" colspan="2" bgcolor="#EEEEEE"><font color="#000000">&nbsp;
			<span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt">10. Data of Reservoirs 
			(GLR and GLSR) </font></span></font></td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
		<tr>
			<td width="208">
				<font face="Verdana" style="font-size: 8.5pt" color="#990000" bgcolor="#F7E6B7">&nbsp;Total no. of GLR:  
				&nbsp;&nbsp;<input type="text" name="num_glrs" id="num_glrs" value="" class="txt5" onKeyUp="showglrs();numeric(this)">
				<!--<input type="button" name="go1" id="go1" value="Go" onClick="showglrs()" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px">--></font>&nbsp;&nbsp;&nbsp;</td>
				
		   <td width="592"><font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;In SC/ ST bastis (Nos.):
		   <input type="text" name="sc_st_glr" id="sc_st_glr" size="20" class="txt5" onKeyUp="numeric(this)"></font></td>
		</tr>
		<tr><td colspan="2">&nbsp;</td></tr>
		<tr>
			<td colspan="2"><div id="show_glrs"></div></td>
		</tr>
		<tr><td colspan="2">&nbsp;</td>
		</tr>
		<tr><td><font face="Verdana" style="font-size: 8.5pt" color="#990000" bgcolor="#F7E6B7">&nbsp;Total no. of GLSR:  
				<input type="text" name="num_glsr" id="num_glsr" value="" class="txt5" onKeyUp="showglsr();show_button();numeric(this)">
				<!--<input type="button" name="go2" id="go2" value="Go" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px" onClick="showglsr()">--></font>	
		</td>
		  <td width="592"><font style="font-size: 8.5pt" face="Verdana" color="#990000">&nbsp;In SC/ ST bastis (Nos.):
		   <input type="text" name="sc_st_glsr" id="sc_st_glsr" size="20" class="txt5" onKeyUp="numeric(this)"></font></td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
			<tr>
				<td colspan="2"><div id="show_glsr"></div></td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>	
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>		
			<tr>
				<td colspan="2">
					<p align="center">
					<input type="submit" value="Click for Continue" name="submit" id="submit", style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px" disabled="disabled">
				</td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
		</table>
  </form>
</div>


</body>
</html>
